package com.atguigu.tree;

import java.util.ArrayList;

/**
 * @author durant
 * @create 2021-11-16 19:48
 */
public class Test {
    public static void main(String[] args) {
         // 以arraylist
        Node node = new Node(1);
        Node node2 = new Node(2);
        Node node3 = new Node(3);
        node.setLeft(node2);
        node2.setLeft(node3);
        node.preList();
    }
}
class Node{
    private  int id;
    private Node left;

    public void setLeft(Node left) {
        this.left = left;
    }

    public Node(int id) {
        this.id = id;
    }
    public void preList(){
        if (this.left != null){
            this.left.preList();
        }
        System.out.println(this);
    }

    @Override
    public String toString() {
        return "Node{" +
                "id=" + id +
                '}';
    }
}
